package com.yy.app.controller;

import jakarta.servlet.http.HttpSession;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @Description
 * @Date 2025/10/11 下午2:24
 * @Author yanglin
 **/
@RestController
@RequestMapping("/api/session")
public class SessionController {
    @GetMapping("/test")
    public String testSession(HttpSession session) {
        String sessionId = session.getId();
        Long creationTime = session.getCreationTime();
        Long lastAccessed = session.getLastAccessedTime();

        return String.format("Session ID: %s<br>Created: %s<br>Last Accessed: %s",
                sessionId, new Date(creationTime), new Date(lastAccessed));
    }

}
